// 练习1
const fp = require('lodash/fp');
const {Maybe, Container} = require('./support');
let maybe = Maybe.of([5, 6, 1]);
let ex1 = (functor) => {
    return functor.map(values => fp.map(value => fp.add(value, 10), values))._value;
}

console.log(ex1(maybe));

// 练习2
let xs = Container.of(['do', 'ray', 'me', 'fa', 'so', 'la', 'ti', 'do']);
let ex2 = (functor) => {
    return functor.map(values => fp.first(values))._value;   
}

console.log(ex2(xs));

// 练习3
let safeProp = fp.curry(function(x, o) {
    return Maybe.of(o[x]);
});

let user = {id: 2, name: 'Albert'};
let ex3 = (user) => {
    return safeProp('name', user).map(name => name.split('')).map(fp.first)._value;
}

console.log(ex3(user));

// 练习4
let ex4 = n => Maybe.of(n).map(parseInt);